//
//  BkFaceDetailSelectView.m
//  TuDianEducation
//
//  Created by lixinkeji on 2021/1/12.
//  Copyright © 2021 zhangbenchao. All rights reserved.
//

#import "BkFaceDetailSelectView.h"
@interface BkFaceDetailSelectView()

@end
@implementation BkFaceDetailSelectView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, TSScreenWidth, TSScaleW(50));
        [self addSubview:self.allCommendsBtn];
        [self addSubview:self.onlyAuthsBtn];
        [self addSubview:self.timeShowBtn];
        self.backgroundColor = kWhiteColor;
        [self.allCommendsBtn sendActionsForControlEvents:(UIControlEventTouchUpInside)];
    }
    return self;
}
-(UIButton *)allCommendsBtn{
    if (!_allCommendsBtn) {
        _allCommendsBtn = [TSWLTools allocButtonTitle:@"全部评论" font:systemFont(TSScaleW(12)) textColor:kSubTxtColor image:nil frame:CGRectMake(0, 0, TSScaleW(75), self.height) sel:@selector(allCommendsBtnAction:) taget:self];
        [_allCommendsBtn setTitleColor:kMainTxtColor forState:(UIControlStateSelected)];
        
    }
    return _allCommendsBtn;
}

-(void)allCommendsBtnAction:(UIButton *)sender
{
    sender.selected = YES;
    sender.titleLabel.font = systemBoldFont(TSScaleW(13));
    _onlyAuthsBtn.titleLabel.font = systemFont(TSScaleW(12));
    _onlyAuthsBtn.selected = NO;
    !self.typeBlock?:self.typeBlock(@"0");
}
-(UIButton *)onlyAuthsBtn{
    if (!_onlyAuthsBtn) {
        _onlyAuthsBtn = [TSWLTools allocButtonTitle:@"只看作者" font:systemFont(TSScaleW(12)) textColor:kSubTxtColor image:nil frame:CGRectMake(_allCommendsBtn.right, 0, TSScaleW(75), self.height) sel:@selector(onlyAuthsBtnAction:) taget:self];
        [_onlyAuthsBtn setTitleColor:kMainTxtColor forState:(UIControlStateSelected)];
    }
    return _onlyAuthsBtn;
}

-(void)onlyAuthsBtnAction:(UIButton *)sender
{
    sender.selected = YES;
    sender.titleLabel.font = systemBoldFont(TSScaleW(13));
    _allCommendsBtn.titleLabel.font = systemFont(TSScaleW(12));
    _allCommendsBtn.selected = NO;
    !self.typeBlock?:self.typeBlock(@"1");
}



-(UIButton *)timeShowBtn{
    if (!_timeShowBtn) {
        _timeShowBtn = [TSWLTools allocButtonTitle:@"时间正序" font:systemFont(TSScaleW(12)) textColor:kGreenColor image:[UIImage imageNamed:@"下拉"] frame:CGRectMake(_allCommendsBtn.right, TSScaleW(10), TSScaleW(75), TSScaleW(22)) sel:@selector(timeShowBtnAction:) taget:self];
        [_timeShowBtn setTitleColor:kMainTxtColor forState:(UIControlStateSelected)];
        [_timeShowBtn setCornerRadius:_timeShowBtn.height/2.f];
        [_timeShowBtn setBorderWithWidth:1 andColor:kGreenColor];
        [_timeShowBtn setBtnLeftLabelRightImgOffSet:TSScaleW(5)];
        _timeShowBtn.right = self.width - TSScaleW(12);
    }
    return _timeShowBtn;
}

-(UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(TSScaleW(11), self.height - .5f, self.width - TSScaleW(22), .5f)];
        _lineView.backgroundColor = kMainLineColor;
    }
    return _lineView;
}
-(void)timeShowBtnAction:(UIButton *)sender
{
    !self.timeShowBlock?:self.timeShowBlock(sender);
}

@end
